<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!-- 头部-导航 -->
<nav class="navbar navbar-expand-lg navbar-light">
    <div class="container"><a href="https://themes.getbootstrap.com" class="navbar-brand">跳蚤</a>
        <div class="d-flex ml-auto">
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#globalNavbar"
                    aria-controls="globalNavbar" aria-expanded="false" aria-label="Toggle navigation"><span
                    class="navbar-toggler-icon"></span></button>
        </div>
        <div class="collapse navbar-collapse" id="globalNavbar">
            <form class="form-inline form-navbar my-2 my-lg-0 order-2" action="${ctx}/products">
                <input class="form-control" name="key" type="text" placeholder="搜索" value="${key}">
            </form>
            <ul class="navbar-nav mr-auto order-1">
                <li class="nav-item"><a class="nav-link" href="${ctx}/products/latest">最新</a></li>
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" id="dropdownMenuButton" href="#" data-toggle="dropdown"
                       aria-haspopup="true" aria-expanded="false">发现</a>
                    <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                        <a class="dropdown-item" href="#">数码</a>
                        <a class="dropdown-item" href="#">服装</a>
                        <a class="dropdown-item" href="#">家具</a>
                        <a class="dropdown-item" href="#">食品</a>
                        <a class="dropdown-item" href="#">娱乐</a>
                    </div>
                </li>
                <li class="nav-item"><a class="nav-link" href="https://themes.getbootstrap.com/guide">热卖</a></li>
                <li class="nav-item"><a class="nav-link" href="https://themes.getbootstrap.com/guide">关于</a></li>
            </ul>
            <c:choose>
                <c:when test="${empty userSession}">
                    <ul class="navbar-nav d-none d-lg-flex ml-2 order-3">
                        <li class="nav-item"><a class="nav-link" href="${ctx}/page/login.jsp">登录</a></li>
                        <li class="nav-item"><a class="nav-link" href="${ctx}/page/register.jsp">注册</a></li>
                    </ul>
                </c:when>
                <c:otherwise>
                    <ul class="navbar-nav d-none d-lg-flex ml-2 order-3">
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle" id="dropdownMenuButton2" href="#" data-toggle="dropdown"
                               aria-haspopup="true" aria-expanded="false">
                                <span class="badge badge-danger badge-pill" id="messageCount">0</span>
                                    ${userSession.nickname}&nbsp;&nbsp;</a>
                            <div class="dropdown-menu" aria-labelledby="dropdownMenuButton2">
                                <a class="dropdown-item" href="${ctx}/user/profile">个人中心</a>
                                <a class="dropdown-item" href="${ctx}/page/user/products.jsp">闲置中心</a>
                                <a class="dropdown-item" href="${ctx}/user/orders">订单中心</a>
                                <a class="dropdown-item" href="${ctx}/logout">退出</a>
                            </div>
                        </li>
                    </ul>
                </c:otherwise>
            </c:choose>
        </div>
    </div>
</nav>